package cn.gene.timeyan.article.webapi.controller;


import cn.gene.timeyan.article.service.IShareService1;
import cn.gene.timeyan.article.service.ShareService;
import cn.gene.timeyan.article.webapi.mapper.ShareMapper;
import cn.gene.timeyan.common.restful.JsonResult;
import cn.gene.timeyan.pojo.article.dto.ShareDTO;

import cn.gene.timeyan.pojo.ums.dto.VIPDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 鐢ㄦ埛鍒嗕韩鏂囩珷鐨勮?褰 前端控制器
 * </p>
 *
 * @author LWG
 * @since 2022-07-25
 */
@Slf4j
@RestController
@RequestMapping("/share")
@Api(tags = "share模块")
public class ShareController {
    /**
     * cyn
     */
    @Autowired(required = false)
    private ShareService shareService;


    @Autowired
    IShareService1 shareService1;

    /**
     * 添加求助
     */
    @ApiOperation("用户分享文章")
    @PostMapping("/addNewShare")
    public JsonResult<Void> addNew(@Validated ShareDTO shareDTO) {
        log.info("dto====:{}", shareDTO);
        shareService.addNewShare(shareDTO);
        return JsonResult.ok();
    }
    /**
     * 我也不知道他为啥要整个和我的几乎一样的代码
     * 生成一个当前帖子的分享链接并粘贴到用户剪贴板上 供用户使用
     *  复制当前网址链接到剪贴板功能我嫖了份js实现
     *  启动项目后访问http://localhost:10004/copy
     *  点一下那个按钮就能复制当前网址到剪贴板
     *
     */
    @RequestMapping("/GenerateShareLink")
    @ApiOperation("生成分享链接")
    @ApiImplicitParams({

            @ApiImplicitParam(value = "用户id",name="userId",example = "3"),
            @ApiImplicitParam(value = "帖子id",name="articleId",example = "1"),
            @ApiImplicitParam(value = "帖子类型id",name="moduleId",example = "2")
    })
    public JsonResult<Void> GenerateShareLink(Long userId, Long articleId, Long moduleId) {


        System.out.println("开始存档");
        int row = shareService1.addShareService(userId,articleId,moduleId);

        return JsonResult.ok();
    }


}

